package com.bridgeintelligent.tag.customer.dto;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * @description
 * @author: grp 2021-01-08 09:58
 **/

@Getter
@Setter
@Accessors(chain = true)
public class CustomersDto<T> {
    //返回数据
    private T data;
    //返回码
    private int code;
    //返回消息
    private String msg;

    public CustomersDto(T data, int code, String msg) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }

    public CustomersDto(T data, int code) {
        this.data = data;
        this.code = code;
    }

    public CustomersDto(int code) {
        this.code = code;
    }

    public CustomersDto(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static<T> CustomersDto<T> success(){
        return new CustomersDto<>(0);
    }
    public static<T> CustomersDto<T> success(T data){
        return new CustomersDto<>(data, 0);
    }

    public static CustomersDto<Object> error(String msg){
        return new CustomersDto<>(999, msg);
    }

    public static<T> CustomersDto<T> error(String msg,T data){
        return new CustomersDto<>(999, msg);
    }
}
